/**
 * Created by asdzheng on 2016/2/15.
 */
$(document).ready(function() {

    $(".index-content-banner").unslider({
        autoplay: true,
        arrows: false
    });

    $(".unslider").css({ "overflow": "hidden", "border-radius": "5px" });

    $(".unslider-nav").find("ol").find("li").each(function() {
        $(this).text("");
    });


    var index = parseInt($('.index-content').offset().top + $('.index-content').outerHeight() - getHeight());
    $(window).bind('scroll', function() {
      

        // $.nmDebug.log("left---",$(window).scrollLeft());

        $(".public-header").css("left","-" + $(window).scrollLeft() + "px");

        if ($(window).scrollTop() >= index) {
            // $.nmDebug.log("------1------>");
         
            if ($('.page').data("page_num") > 10) {

                if ($('.index-business-list').size() < 11) {
                    // $.nmDebug.log("------------>");
                    $('.index-content-loading').css("display", "inline-block");
                    setTimeout(function() {
                        $('.index-content-loading').css("display", "none");
                        if ($('.page').data("count") > 1) {
                            $('.page').removeClass("page-hide");
                        }
                        $(".index-business-list-hide").addClass("index-business-list");
                        $(".index-business-list-hide").removeClass("index-business-list-hide");

                    }, 1000)
                }
            } else {
                if ($('.page').data("count") > 1) {
                    $('.page').removeClass("page-hide");
                }
            }
        } else {
            if ($('.index-business-list').size() < 10) {
                $('.index-content-loading').css("display", "none");
                setTimeout(function() {

                    if ($('.page').data("count") > 1) {
                        $('.page').removeClass("page-hide");
                    }

                }, 10)
            }
        }

        resizeIndexRight();
    });

    $(window).resize(function() {
        resizeIndexRight();
    });
});

function resizeIndexRight() {
    var offset = $(".index-content-right").offset();

    var footer = $(".public-inner-footer");
    var left = offset.left - $(window).scrollLeft();
    //var window =;
    if ($(window).scrollTop() >= $(".index-content-right").offset().top - 84) {
        var footerTop = $(window).scrollTop() + $(window).height() - footer.offset().top;
        var bottom = footerTop;
     
        if (footerTop > 0) {
        

            if ($(window).height() - 84 - footerTop < $(".inner").height()) {
 
                $(".inner").css({ "position": "fixed", "bottom": bottom + "px", "left": left + "px", "top": "auto" });
            } else {
           
                // $(".inner").css({ "position": "fixed" , "bottom": bottom + "px", "left": left + "px" ,"top": "auto"});
            }
        } else {
 
            $(".inner").css({ "position": "fixed", "top": 84 + "px", "left": left + "px", "bottom": "auto" });
        }
    } else {
        $(".inner").css({ "position": "relative", "top": "0", "left": "0", "bottom": "auto" });
    }
}
